package com.after.saas.system.easyexcel;

import cn.hutool.json.JSONUtil;
import com.after.saas.common.model.bo.OkxMoneyBO;
import com.alibaba.excel.context.AnalysisContext;
import com.alibaba.excel.event.AnalysisEventListener;
import lombok.Getter;
import lombok.extern.slf4j.Slf4j;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/**
 * @Classname ExcelListener
 * @Description TODO
 * @auth after
 * @since 2023/9/15 22:11
 */

@Slf4j
@Getter
public class ExcelListener<T> extends AnalysisEventListener<T> {

    private final List<T> data = new ArrayList<>();

    /**
     * 一行一行的读取excel内容
     */
    public void invoke(T okx, AnalysisContext analysisContext) {
        data.add(okx);
    }

    /**
     * 读取表头内容
     */
    public void invokeHeadMap(Map<Integer, String> headMap, AnalysisContext context) {
        log.info("表头{}", headMap);
    }

    /**
     * 读取完成操作
     */
    public void doAfterAllAnalysed(AnalysisContext analysisContext) {
        log.info("读取Excel完毕,共读取{}行",data.size());
    }
}
